﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Security.Principal;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using text.Utils;

namespace text
{
    public partial class Site1 : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] != null)
            {
                DataRow userRow = (DataRow)Session["User"];
                //查到登录用户的权限
                int manage = Convert.ToInt32(userRow["manager"]);
                if (manage == 0)
                {
                    lbtnUserManage.Visible = false;
                    liUserManager.Visible = false;
                }

                Image1.ImageUrl = userRow["img_url"].ToString();
                Label1.Text = userRow["account"].ToString();
            }
        }
        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            Response.Redirect("user.aspx");
        }
        protected void LinkButton3_Click(object sender, EventArgs e)
        {
            Response.Redirect("user.aspx");
        }
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            //1.清Session
            Session.Clear();
            //2.删cookie
            HttpCookie accoutCookie = new HttpCookie("account");
            accoutCookie.Value =" account";
            accoutCookie.Expires = DateTime.Now;
            Response.Cookies.Add(accoutCookie);
    //什么都没改
            Response.Redirect("login.aspx");
        }
        protected void LinkButton5_Click(object sender, EventArgs e)
        {
            DataRow userRow = (DataRow)Session["User"];
            int id=Convert.ToInt32(userRow["id"]);
            Response.Redirect("info.aspx?id="+id);
        }
        protected void LinkButton4_Click(object sender, EventArgs e)
        {
            DataRow userRow = (DataRow)Session["User"];
            int id = Convert.ToInt32(userRow["id"]);
            Response.Redirect("info.aspx?id=" + id);
        }
    }
}